1
2
3
4
5
6
7
8
9 package ca.uhn.cache.impl;
10
11 import java.util.HashSet;
12 import java.util.Set;
13
14 import junit.framework.TestCase;
15 import ca.uhn.cache.IDimension;
16 import ca.uhn.cache.IQueryParam;
17
18 /***
19 * TODO complete javadoc for
20 *
21 * @author <a href="mailto:alexei.guevara@uhn.on.ca">Alexei Guevara </a>
22 * @version $Revision: 1.1 $ updated on $Date: 2005/01/24 22:51:46 $ by $Author:
23 * ag $
24 */
25 public class QueryTest extends TestCase {
26
27
28 static {
29 ClassLoader.getSystemClassLoader().setPackageAssertionStatus( "ca.uhn.cache", true );
30 }
31
32 private Query myQuery;
33
34 private IDimension myDimension;
35
36
37
38
39 protected void setUp() throws Exception {
40 super.setUp();
41
42 myQuery = new Query();
43 myDimension = new Dimension( "stringDimension", new Class[] { StringParam.class } );
44 }
45
46
47
48
49 protected void tearDown() throws Exception {
50 super.tearDown();
51 }
52
53 /***
54 */
55 public void test1() {
56 try {
57 myQuery.addParameter( null );
58 fail( "AssertionError must be thrown" );
59 }
60 catch (AssertionError e) {
61 }
62 }
63
64 /***
65 */
66 public void test2() {
67 Set expectedQps = new HashSet();
68
69 IQueryParam qp1 = new StringParam( myDimension, "value" );
70 expectedQps.add( qp1 );
71 myQuery.addParameter( qp1 );
72
73 Set actualQps = myQuery.getParameters();
74
75 assertEquals( expectedQps, actualQps );
76 }
77
78 /***
79 */
80 public void test3() {
81 IQueryParam qp1 = new StringParam( myDimension, "value1" );
82 IQueryParam qp2 = new StringParam( myDimension, "value2" );
83
84 myQuery.addParameter( qp1 );
85
86 try {
87 myQuery.addParameter( qp2 );
88 fail( "AssertionError must be thrown" );
89 }
90 catch ( AssertionError e ) {
91 }
92 }
93
94 }